"""
基础数据库连接器接口
"""
from abc import ABC, abstractmethod
from typing import Dict, Any, Union
from sqlalchemy.engine import Engine
from sqlalchemy.orm import sessionmaker


class BaseConnector(ABC):
    """
    基础数据库连接器接口
    """
    @abstractmethod
    def connect(self, connection_params: Dict[str, Any]) -> Union[Engine, sessionmaker]:
        """
        连接数据库
        
        Args:
            connection_params: 连接参数
        Returns:
            SQLAlchemy Engine 或 Session 工厂
        """
        pass

    @abstractmethod
    def execute_query(self, query: str) -> Dict[str, Any]:
        """
        执行 SQL 查询
        
        Args:
            query: SQL 查询语句
        """
        pass

    @abstractmethod
    def close(self) -> None:
        """
        关闭数据库连接
        """
        pass